﻿using System.Collections;
using System.Collections.Specialized;
using System.Windows.Controls;

namespace UIKit.Controls
{
    public class SuperItemsControl : ItemsControl
    {
        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    AddItems(e.OldItems, e.NewItems,e.OldStartingIndex, e.NewStartingIndex);
                    break;
                case NotifyCollectionChangedAction.Remove:
                    RemoveItems(e.OldItems, e.NewItems, e.OldStartingIndex, e.NewStartingIndex);
                    break;
                case NotifyCollectionChangedAction.Replace:
                    ReplaceItems(e.OldItems, e.NewItems, e.OldStartingIndex, e.NewStartingIndex);
                    break;
                case NotifyCollectionChangedAction.Reset:
                    //AddItems(e.OldItems, e.NewItems, e.OldStartingIndex, e.NewStartingIndex);
                    break;
            }
        }

        protected virtual void AddItems(IList oldItems, IList newItems,int oldStartingIndex, int newStartingIndex)
        {
            
        }

        protected virtual void RemoveItems(IList oldItems, IList newItems, int oldStartingIndex, int newStartingIndex)
        {

        }

        protected virtual void ReplaceItems(IList oldItems, IList newItems, int oldStartingIndex, int newStartingIndex)
        {

        }
    }
}
